home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-SPAR.{_6 / PGTSUN4.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  5KB  |  163 lines

  1. /* $Id: pgtsun4.h,v 1.4 1998/07/26 03:05:42 davem Exp $
  2.  * pgtsun4.h:  Sun4 specific pgtable.h defines and code.
  3.  *
  4.  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5.  * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  6.  */
  7. #ifndef _SPARC_PGTSUN4C_H
  8. #define _SPARC_PGTSUN4C_H
  9.  
  10. #include <asm/contregs.h>
  11.  
  12. /* PMD_SHIFT determines the size of the area a second-level page table can map */
  13. #define SUN4C_PMD_SHIFT       23
  14. #define SUN4C_PMD_SIZE        (1UL << SUN4C_PMD_SHIFT)
  15. #define SUN4C_PMD_MASK        (~(SUN4C_PMD_SIZE-1))
  16. #define SUN4C_PMD_ALIGN(addr) (((addr)+SUN4C_PMD_SIZE-1)&SUN4C_PMD_MASK)
  17.  
  18. /* PGDIR_SHIFT determines what a third-level page table entry can map */
  19. #define SUN4C_PGDIR_SHIFT       23
  20. #define SUN4C_PGDIR_SIZE        (1UL << SUN4C_PGDIR_SHIFT)
  21. #define SUN4C_PGDIR_MASK        (~(SUN4C_PGDIR_SIZE-1))
  22. #define SUN4C_PGDIR_ALIGN(addr) (((addr)+SUN4C_PGDIR_SIZE-1)&SUN4C_PGDIR_MASK)
  23.  
  24. /* To represent how the sun4c mmu really lays things out. */
  25. #define SUN4C_REAL_PGDIR_SHIFT       18
  26. #define SUN4C_REAL_PGDIR_SIZE        (1UL << SUN4C_REAL_PGDIR_SHIFT)
  27. #define SUN4C_REAL_PGDIR_MASK        (~(SUN4C_REAL_PGDIR_SIZE-1))
  28. #define SUN4C_REAL_PGDIR_ALIGN(addr) (((addr)+SUN4C_REAL_PGDIR_SIZE-1)&SUN4C_REAL_PGDIR_MASK)
  29.  
  30. /* 19 bit PFN on sun4 */
  31. #define SUN4C_PFN_MASK 0x7ffff
  32.  
  33. /* Don't increase these unless the structures in sun4c.c are fixed */
  34. #define SUN4C_MAX_SEGMAPS 256
  35. #define SUN4C_MAX_CONTEXTS 16
  36.  
  37. /*
  38.  * To be efficient, and not have to worry about allocating such
  39.  * a huge pgd, we make the kernel sun4c tables each hold 1024
  40.  * entries and the pgd similarly just like the i386 tables.
  41.  */
  42. #define SUN4C_PTRS_PER_PTE    1024
  43. #define SUN4C_PTRS_PER_PMD    1
  44. #define SUN4C_PTRS_PER_PGD    1024
  45.  
  46. /* On the sun4 the physical ram limit is 128MB.  We set up our I/O
  47.  * translations at KERNBASE + 128MB for 1MB, then we begin the VMALLOC
  48.  * area, makes sense.  This works out to the value below.
  49.  */
  50. #define SUN4C_VMALLOC_START   (0xfe300000)
  51. #define SUN4C_VMALLOC_END     ~0x0UL
  52.  
  53. /*
  54.  * Sparc SUN4C pte fields.
  55.  */
  56. #define _SUN4C_PAGE_VALID        0x80000000
  57. #define _SUN4C_PAGE_SILENT_READ  0x80000000   /* synonym */
  58. #define _SUN4C_PAGE_DIRTY        0x40000000
  59. #define _SUN4C_PAGE_SILENT_WRITE 0x40000000   /* synonym */
  60. #define _SUN4C_PAGE_PRIV         0x20000000   /* privileged page */
  61. #define _SUN4C_PAGE_NOCACHE      0x10000000   /* non-cacheable page */
  62. #define _SUN4C_PAGE_PRESENT      0x08000000   /* implemented in software */
  63. #define _SUN4C_PAGE_IO           0x04000000   /* I/O page */
  64. #define _SUN4C_PAGE_READ         0x00800000   /* implemented in software */
  65. #define _SUN4C_PAGE_WRITE        0x00400000   /* implemented in software */
  66. #define _SUN4C_PAGE_ACCESSED     0x00200000   /* implemented in software */
  67. #define _SUN4C_PAGE_MODIFIED     0x00100000   /* implemented in software */
  68.  
  69. #define _SUN4C_READABLE        (_SUN4C_PAGE_READ|_SUN4C_PAGE_SILENT_READ|\
  70.                  _SUN4C_PAGE_ACCESSED)
  71. #define _SUN4C_WRITEABLE    (_SUN4C_PAGE_WRITE|_SUN4C_PAGE_SILENT_WRITE|\
  72.                  _SUN4C_PAGE_MODIFIED)
  73.  
  74. #define _SUN4C_PAGE_CHG_MASK    (0xffff|_SUN4C_PAGE_ACCESSED|_SUN4C_PAGE_MODIFIED)
  75.  
  76. #define SUN4C_PAGE_NONE        __pgprot(_SUN4C_PAGE_PRESENT)
  77. #define SUN4C_PAGE_SHARED    __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE|\
  78.                      _SUN4C_PAGE_WRITE)
  79. #define SUN4C_PAGE_COPY        __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE)
  80. #define SUN4C_PAGE_READONLY    __pgprot(_SUN4C_PAGE_PRESENT|_SUN4C_READABLE)
  81. #define SUN4C_PAGE_KERNEL    __pgprot(_SUN4C_READABLE|_SUN4C_WRITEABLE|\
  82.                      _SUN4C_PAGE_DIRTY|_SUN4C_PAGE_PRIV)
  83.  
  84. #ifndef __ASSEMBLY__
  85.  
  86. extern __inline__ unsigned long sun4c_get_synchronous_error(void)
  87. {
  88.     unsigned long sync_err;
  89.  
  90.     __asm__ __volatile__("lda [%1] %2, %0\n\t" :
  91.                  "=r" (sync_err) :
  92.                  "r" (AC_SYNC_ERR), "i" (ASI_CONTROL));
  93.     return sync_err;
  94. }
  95.  
  96. extern __inline__ unsigned long sun4c_get_synchronous_address(void)
  97. {
  98.     unsigned long sync_addr;
  99.  
  100.     __asm__ __volatile__("lda [%1] %2, %0\n\t" :
  101.                  "=r" (sync_addr) :
  102.                  "r" (AC_SYNC_VA), "i" (ASI_CONTROL));
  103.     return sync_addr;
  104. }
  105.  
  106. /* SUN4 pte, segmap, and context manipulation */
  107. extern __inline__ unsigned long sun4c_get_segmap(unsigned long addr)
  108. {
  109.   register unsigned long entry;
  110.  
  111.   __asm__ __volatile__("\n\tlduha [%1] %2, %0\n\t" : 
  112.                "=r" (entry) :
  113.                "r" (addr), "i" (ASI_SEGMAP));
  114.   return entry;
  115. }
  116.  
  117. extern __inline__ void sun4c_put_segmap(unsigned long addr, unsigned long entry)
  118. {
  119.   __asm__ __volatile__("\n\tstha %1, [%0] %2; nop; nop; nop;\n\t" : :
  120.                "r" (addr), "r" (entry),
  121.                "i" (ASI_SEGMAP));
  122. }
  123.  
  124. extern __inline__ unsigned long sun4c_get_pte(unsigned long addr)
  125. {
  126.   register unsigned long entry;
  127.  
  128.   __asm__ __volatile__("\n\tlda [%1] %2, %0\n\t" : 
  129.                "=r" (entry) :
  130.                "r" (addr), "i" (ASI_PTE));
  131.   return entry;
  132. }
  133.  
  134. extern __inline__ void sun4c_put_pte(unsigned long addr, unsigned long entry)
  135. {
  136.   __asm__ __volatile__("\n\tsta %1, [%0] %2; nop; nop; nop;\n\t" : :
  137.                "r" (addr), 
  138.                "r" ((entry & ~(_SUN4C_PAGE_PRESENT))), "i" (ASI_PTE));
  139. }
  140.  
  141. extern __inline__ int sun4c_get_context(void)
  142. {
  143.   register int ctx;
  144.  
  145.   __asm__ __volatile__("\n\tlduba [%1] %2, %0\n\t" :
  146.                "=r" (ctx) :
  147.                "r" (AC_CONTEXT), "i" (ASI_CONTROL));
  148.  
  149.   return ctx;
  150. }
  151.  
  152. extern __inline__ int sun4c_set_context(int ctx)
  153. {
  154.   __asm__ __volatile__("\n\tstba %0, [%1] %2; nop; nop; nop;\n\t" : :
  155.                "r" (ctx), "r" (AC_CONTEXT), "i" (ASI_CONTROL));
  156.  
  157.   return ctx;
  158. }
  159.  
  160. #endif /* !(__ASSEMBLY__) */
  161.  
  162. #endif /* !(_SPARC_PGTSUN4_H) */
  163.